class Solution(object):
    def confusingNumber(self, n):
        """
        :type n: int
        :rtype: bool
        """
        d = {'1': '1', '0': '0', '6': '9', '8': '8', '9': '6'}
        n = str(n)
        t = ''
        for i in range(len(n)):
            if n[i] not in d:
                return False
            else:
                t += d[n[i]]
        t = t[::-1]
        return t != n

